﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

/// <summary>
/// 判断用户是否登录
/// </summary>
public class IsLoginAttribute : AuthorizeAttribute
{
    /// <summary>
    /// 判断用户是否登录
    /// </summary>
    /// <param name="httpContext"></param>
    /// <returns></returns>
    protected override bool AuthorizeCore(HttpContextBase httpContext)
    {
        var userinfo = LoginModel.User;
        if (userinfo == null || userinfo.Uid == 0)
        {
            httpContext.Response.Redirect("/Login/?callback=" + httpContext.Request.Url.ToString());
            return false;
        }
        return true;
    }
}